package top.kaoshanji.p1ch03b;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import top.kaoshanji.u1constant.FileConstant;

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.attribute.FileTime;

/**
 * 代码清单 p1ch03b-09：获取文件的上次修改时间的示例
 * author kaoshanji
 * ^_^
 * create time 2025/1/10 21:05
 */
public class FileAttributesExample02 {

    private static final Logger logger = LogManager.getLogger(FileAttributesExample02.class);

    public static void main(String[] args) throws IOException {
        logger.info("...代码清单 p1ch03b-09：获取文件的上次修改时间的示例...");

        Path path = Paths.get(FileConstant.LOCAL_ROOT_PATH.concat("深入理解Java7：核心技术与最佳实践-成富-随书源码.7z"));
        FileTime lastModifiedTime = (FileTime)Files.getAttribute(path, "lastModifiedTime");

        System.out.println(lastModifiedTime.toMillis());

    }


}
